#ifndef PLAYER_H
#define PLAYER_H

#include <vector>
#include <time.h>
#include "vector.h"
#include "weapons/weapon.h"
#include "weapons/weapons.h"

enum Action {NOTHING, STOP, TAKE_GUN};

class Player
{
	public:
		//getters and setters
		float getFrontBackSpeed();
		float getLeftRightSpeed();
		float getUpDownSpeed();
		bool getIsOnTheGround();
		double getBounce();
		Vector getPosition();
		Weapon* getWeapon();
		void setNumberOfTrianglesToCollide(int numberOfTriangles);
		void setTrianglesToCollide(Vector* triangles);

		//methods
		~Player();
		static Player* createNewPlayer();
		void init();
		void move(short frontBack, short leftRight, short upDown);
		void shoot();
		void jump();
		void death();
		void damage(int hpDamaged);
		void handleTurning(int x, int y);
		void setSpeed(short frontBack, short leftRight, short upDown);
		void changeWeapon(short i);
		bool isShooting();

	private:
		Player();

		static Player *player;
		Vector position;
		float size;
		Weapon *weapon;
		Vector* trianglesToCollide;
		long numberOfTrianglesToCollide;

		float frontBackSpeed;
		float leftRightSpeed;
		float upDownSpeed;
		float jumpStrength;
		float maxSpeed;
		float acceleration;
		float deceleration;
		double bounce;

		bool isJumping;
		bool isOnTheGround;

		//angles of turning
		double alpha;
		double theta;

		//angles for moving (unchangable when jumping, the same when walking)
		double moveAlpha;
		double moveTheta;

		//mouse position in previous frame
		int lastx, lasty;
		float lastMoveX, lastMoveY, lastMoveZ;
		
		//methods
		void checkCollisions();
		void changePosition();
		void setCamera();
		void setBounce();
		void turn(double kalpha, double ktheta);
		void hitTheGround(float antigravity);
};

#endif //PLAYER_H